package com.winning.pmph.utils;

import com.winning.pmph.entity.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Objects;

/**
 * @author 王闯
 */
public class PMPHAppUtil {

	/**  */
	public final static ThreadLocal<String> threadUsername = new ThreadLocal<>();

	public static User getCrtUser() {
		HttpSession session = ApplicationContextUtil.getSession();
		return Objects.isNull(session) ? null : (User) session.getAttribute("crtUser");
	}

	public static String getCurrentUserEnName() {
        User crtUser = getCrtUser();
        return Objects.isNull(crtUser) ? threadUsername.get() : crtUser.getUserName();
    }

	public static String getCurrentUserCnName() {
		User crtUser = getCrtUser();
		return Objects.isNull(crtUser) ? null : crtUser.getName();
	}
}
